var testTempo = false;

function afficherTempo(event) {
	if(testerConditionTempo(event.srcElement) == true && testTempo == false) {
		testTempo = true;
		div = document.getElementById('corps');
		for (i=0; i<div.children.length; i++) {
			enfant = div.children[i];
			if (enfant.className == 'bloc') {
				break;
			}
		}
		html = '<div style="margin:10px 0px 20px 40px; text-align:center">';
		html += '<img src="../smartbok/images/loading.gif" width="40" height="40" alt="traitement en cours" />';
		html += '<p style="padding:15px 0px 0px 60px;">Votre requête est en cours de traitement, veuillez patientez ...</p></div>';
		enfant.children[1].style.display = "none";//innerHTML = html;
		tempo = document.createElement('div');
		tempo.className = "content";
		tempo.innerHTML = html;
		enfant.appendChild(tempo);
		event.returnValue=true;
	}
}
function testerConditionTempo(objet) {
	switch (objet.tagName) {
		case 'A':
			if (objet.target == '_blank') {
				return false;
			}
			else if(objet.href.substr(0,10) == 'javascript') {
				return false;
			}
		break;
		
		case 'INPUT':
			if (objet.type != 'submit') {
				return false;
			}
		break;
		
		case 'FORM': //traitement des cas IE
			
		break;
			
		default:
			return false;
	}
	return true;
}

function chargerTempo() {
	img = new Image()
	img.src = '../smartbok/images/loading.gif';
    if (window.addEventListener) {
    	window.addEventListener('submit', afficherTempo)
    	window.addEventListener('click', afficherTempo)
    } else if (window.attachEvent) {
    	if (window.document.forms.length >0) {
	    	form = window.document.forms[0];
	    	form.attachEvent('onsubmit', afficherTempo)
    	}
    	document.attachEvent('onclick', afficherTempo)
    }
}

if (window.addEventListener) { 
	window.addEventListener("load", chargerTempo);
} 
else if (window.attachEvent) { 
	// IE 
	window.attachEvent("onload", chargerTempo);
}